package commons.entity;

import com.alibaba.fastjson.JSONObject;
import commons.util.GameUtil;
import gudaziEx.util.ChainUtil;

public class CpMissonResults {
    private boolean[] accountSignState;

    private boolean[] accountTrainState;

    private boolean[] accountRewardState;

    private boolean cpRunningState;

    private boolean cpStateReport;

    private String cpRunningDate;


    public static CpMissonResults  getInstance(){
        String filepath = NativeCp.getUserDir() + "/config/"+Constant.FGO+"/CpMissonResults.json";
        CpMissonResults cpMissonResults = JSONObject.parseObject(GameUtil.getJsonString(filepath), CpMissonResults.class);
        return cpMissonResults;

    }

    public boolean[] getAccountSignState() {
        return accountSignState;
    }

    public void setAccountSignState(boolean[] accountSignState) {
        this.accountSignState = accountSignState;
    }

    public boolean[] getAccountTrainState() {
        return accountTrainState;
    }

    public void setAccountTrainState(boolean[] accountTrainState) {
        this.accountTrainState = accountTrainState;
    }

    public boolean[] getAccountRewardState() {
        return accountRewardState;
    }

    public void setAccountRewardState(boolean[] accountRewardState) {
        this.accountRewardState = accountRewardState;
    }

    public boolean isCpRunningState() {
        return cpRunningState;
    }

    public void setCpRunningState(boolean cpRunningState) {
        this.cpRunningState = cpRunningState;
    }

    public String getCpRunningDate() {
        return cpRunningDate;
    }

    public void setCpRunningDate(String cpRunningDate) {
        this.cpRunningDate = cpRunningDate;
    }

    public boolean isCpStateReport() {
        return cpStateReport;
    }

    public void setCpStateReport(boolean cpStateReport) {
        this.cpStateReport = cpStateReport;
    }

    public static void initCpStateFile(){
        CpMissonResults cr = new CpMissonResults();
        cr.setCpRunningDate(GameUtil.getNowDateString());
        cr.setCpRunningState(true);
        cr.setCpStateReport(true);
        int size = GameUtil.strToIntArray(GameUtil.getValueFromConfig("FgoSignArray"), false).length;
        boolean[] accountSignState = new boolean[size];
        size = GameUtil.strToIntArray(GameUtil.getValueFromConfig("FgoArray"), false).length;
        boolean[] accountTrainState = new boolean[size];
        size = GameUtil.strToIntArray(GameUtil.getValueFromConfig("FgoRewardArray"), false).length;
        boolean[] accountRewardState = new boolean[size];

        for (int i = 0; i < size; i++) {
            accountSignState[i] = false;
            accountTrainState[i] = false;
            accountRewardState[i] = false;
        }
        cr.setAccountRewardState(accountRewardState);
        cr.setAccountSignState(accountSignState);
        cr.setAccountTrainState(accountTrainState);
        ChainUtil.saveCpMissonResults(cr);
    }
}
